package com.axisdesign.client;

import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class MainFrame extends Composite{
	final String contactLink = DOCstring.getWndVariable("contact");
	
	HorizontalPanel mainPanel;
	VerticalPanel centerPanel;
	AbsolutePanel topPanel;
	ContentFrame contentPanel;
	HorizontalPanel topNavigationPanel;
	
	FlipImage topNavigationHome;
	FlipImage topNavigationPrinting;
	FlipImage topNavigationWebsite;
	FlipImage topNavigationOtherservices;
	FlipImage topNavigationContact;
	
	
	public MainFrame() {
		mainPanel = new HorizontalPanel();
		centerPanel = new VerticalPanel();
		topPanel = new AbsolutePanel();
		contentPanel = new ContentFrame();
		topNavigationPanel = new HorizontalPanel();
		
		mainPanel.setStyleName("mainFrame");
		contentPanel.setStyleName("mainFrame-contentPanel");

		topNavigationHome = new FlipImage(
			new PNGImage2("images/mainFrame/top/home_a.png",60,29)
			,new PNGImage2("images/mainFrame/top/home_b.png",60,29)
			,false
		);
		topNavigationPrinting = new FlipImage(
				new PNGImage2("images/mainFrame/top/printing_a.png",88,29)
				,new PNGImage2("images/mainFrame/top/printing_b.png",88,29)
				,true
			);
		topNavigationWebsite = new FlipImage(
				new PNGImage2("images/mainFrame/top/website_a.png",85,29)
				,new PNGImage2("images/mainFrame/top/website_b.png",85,29)
				,true
			);
		topNavigationOtherservices = new FlipImage(
				new PNGImage2("images/mainFrame/top/otherservices_a.png",136,29)
				,new PNGImage2("images/mainFrame/top/otherservices_b.png",136,29)
				,true
			);
		topNavigationContact = new FlipImage(
				new PNGImage2("images/mainFrame/top/contact_a.png",82,29)
				,new PNGImage2("images/mainFrame/top/contact_b.png",82,29)
				,true
			);
		
		init();
		initWidget(mainPanel);
	}
	
	private void init() {
		topNavigationPanel.add(topNavigationHome);
		topNavigationPanel.add(topNavigationPrinting);
		topNavigationPanel.add(topNavigationWebsite);
		topNavigationPanel.add(topNavigationOtherservices);
		topNavigationPanel.add(topNavigationContact);
		
		topPanel.add(new PNGImage2("images/mainFrame/top/logo.png",282,86),0,0);
		topPanel.add(topNavigationPanel,450,50);
		topPanel.setPixelSize(911, 87);
		
		centerPanel.add(topPanel);
		centerPanel.add(contentPanel);
		
		mainPanel.add(centerPanel);
		
		topNavigationHome.addClickListener(new ClickListener() {public void onClick(Widget sender) {queue(-1);}});
		topNavigationPrinting.addClickListener(new ClickListener() {public void onClick(Widget sender) {queue(0);}});
		topNavigationWebsite.addClickListener(new ClickListener() {public void onClick(Widget sender) {queue(1);}});
		topNavigationOtherservices.addClickListener(new ClickListener() {public void onClick(Widget sender) {queue(2);}});
		topNavigationContact.addClickListener(new ClickListener() {public void onClick(Widget sender) {HrefLink.gotoLink(contactLink);}});
	}
	
	public void queue(int status) {
		topNavigationPrinting.setImage1Default(true);
		topNavigationWebsite.setImage1Default(true);
		topNavigationOtherservices.setImage1Default(true);
		topNavigationContact.setImage1Default(true);
		topNavigationHome.setImage1Default(true);
		if(status==0) {
			topNavigationPrinting.setImage1Default(false);
		}
		else if(status==1) {
			topNavigationWebsite.setImage1Default(false);
		}
		else if(status==2) {
			topNavigationOtherservices.setImage1Default(false);
		}
		else if(status==3) {
			topNavigationContact.setImage1Default(false);
		}
		else {
			topNavigationHome.setImage1Default(false);
		}
		
		topNavigationHome.checkAllStatus();
		contentPanel.queue(status);
	}
}
